<?php

namespace Regard\NewsBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class NewsType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('date', 'datetime', array('required' => false))
            ->add('title', 'text')
            ->add('tags', 'text')
            ->add('content', 'textarea')
            ->add('isToPublish', 'checkbox', array('required' => false))
            ->add('image', 'file', array('data_class' => null,
										'property_path' => 'image',
										'required' => false))
        ;
		$builder->remove('date');
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Regard\NewsBundle\Entity\News'
        ));
    }

    public function getName()
    {
        return 'regard_newsbundle_newstype';
    }
}
